package gui;

import java.awt.Color;
import java.awt.Rectangle;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import client.quit;

public class EmployeeCatalogOP extends JFrame{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel mainform = null;
	private JLabel jLabelCatalogOptions = null;
	private JButton jButtonAddNewItem = null;
	private JButton jButtonSearch = null;
	private JButton jButtonHelp = null;
	private JButton jButtonExit = null;
	private JButton jButtonBack = null;
	private JButton jButtonGoSearch = null;
	private AddItemCatalog aic;
	private CustomerCatalog cc;
	private JButton displayButton = null;
	private RemoveItemCatalog ric;
	private UpdateSale usc;
	private JButton saleButton = null;
	public EmployeeCatalogOP() {
		super();
		initialize();
	}
	
	void quit (){
		String userName;
		userName = MainPanel.Userinfo[3];
		quit q = new quit(userName);
		q.closeWindow();
	}

	/**
	 * 
	 */
	private void initialize() {
		this.setSize(1000, 733);
		this.pack();
		this.setContentPane(MainCatalogOPForm());
		this.setTitle("CATALOG OPTIONS");
		this.addWindowListener(new java.awt.event.WindowAdapter() {   
			public void windowClosing(java.awt.event.WindowEvent e) {    
				quit();
				System.out.println("windowClosing()"); 
			}
		
		});
		this.aic=new AddItemCatalog();
		this.ric = new RemoveItemCatalog();
	    this.cc = new CustomerCatalog();
	    this.usc = new UpdateSale();
		cc.getBackButton().addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent e) {
				setContentPane(mainform);
			}
		});
		aic.addToCatalogBotton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent e) {
				setContentPane(mainform);
			}
		});
		ric.backButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent e) {
				setContentPane(mainform);
			}
		});
		ric.backButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent e) {
				setContentPane(mainform);
			}
		});	
		usc.getBackButton().addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent e) {
				setContentPane(mainform);
			}
		});	
		aic.getBackjButton().addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent e) {
				setContentPane(mainform);
			}
		});	
		this.setVisible(true);
	}
	private JPanel MainCatalogOPForm() {
		if (mainform == null) {
			jLabelCatalogOptions = new JLabel();
			jLabelCatalogOptions.setBounds(new Rectangle(151, 44, 644, 109));
			jLabelCatalogOptions.setText("CATALOG OPTIONS");			
			mainform = new JPanel();			
			mainform.setLayout(null);
			mainform.setBackground(Color.CYAN); 
			mainform.add(jLabelCatalogOptions, null);
			mainform.add(getJButtonAddNewItem(), null);
			mainform.add(getJButtonSearch(), null);
			mainform.add(getJButtonHelp(), null);
			mainform.add(getJButtonExit(), null);
			mainform.add(getJButtonBack(), null);
			mainform.add(getJButtonGoSearch(), null);
			mainform.add(getDisplayButton(), null);
			mainform.add(getSaleButton(), null);
		}
		return mainform; 
	}

	/**
	 * This method initializes jButtonAddNewItem	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonAddNewItem() {
		if (jButtonAddNewItem == null) {
			jButtonAddNewItem = new JButton();
			jButtonAddNewItem.setBounds(new Rectangle(75, 180, 167, 76));
			jButtonAddNewItem.setText("ADD NEW ITEM");	
			jButtonAddNewItem.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					setContentPane(aic);
				}
			});
		}
		return jButtonAddNewItem;
	}

	/**
	 * This method initializes jButtonSearch	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonSearch() {
		if (jButtonSearch == null) {
			jButtonSearch = new JButton();
			jButtonSearch.setBounds(new Rectangle(572, 178, 167, 76));
			jButtonSearch.setText("DELETE ITEM");
			jButtonSearch.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					ric.getItems();
					setContentPane(ric);
				}
			});
		}
		return jButtonSearch;
	}

	/**
	 * This method initializes jButtonHelp	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonHelp() {
		if (jButtonHelp == null) {
			jButtonHelp = new JButton();
			jButtonHelp.setBounds(new Rectangle(45, 615, 123, 47));
			jButtonHelp.setText("HELP");
		}
		return jButtonHelp;
	}

	/**
	 * This method initializes jButtonExit	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonExit() {
		if (jButtonExit == null) {
			jButtonExit = new JButton();
			jButtonExit.setBounds(new Rectangle(871, 615, 76, 47));
			jButtonExit.setText("EXIT");
			jButtonExit.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					
					ExitFrame EFrame = new ExitFrame();
				    EFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
				    EFrame.setSize( 300,200 ); // set frame size
				    EFrame.setResizable(true);
				    EFrame.setVisible( true ); // display frame
		
				    
				    
				}
			});
		}
		return jButtonExit;
	}

	/**
	 * This method initializes jButtonBack	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonBack() {
		if (jButtonBack == null) {
			jButtonBack = new JButton();
			jButtonBack.setBounds(new Rectangle(778, 615, 90, 47));
			jButtonBack.setText("BACK");
			jButtonBack.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					MainEmployee MFrame = new MainEmployee();
				    MFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
				    MFrame.setSize( 1000,720 ); // set frame size
				    MFrame.setResizable(true);
				    MFrame.setVisible( true ); // display frame
				    
				    EmployeeCatalogOP.this.dispose();
				}
			});
		}
		return jButtonBack;
	}

	/**
	 * This method initializes jButtonGoSearch	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonGoSearch() {
		if (jButtonGoSearch == null) {
			jButtonGoSearch = new JButton();
			jButtonGoSearch.setBounds(new Rectangle(844, 508, 96, 47));
			jButtonGoSearch.setText("SEARCH");
			jButtonGoSearch.setVisible(false);
		}
		return jButtonGoSearch;
	}
	/**
	 * This method initializes displayButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getDisplayButton() {
		if (displayButton == null) {
			displayButton = new JButton();
			displayButton.setBounds(new Rectangle(577, 312, 158, 65));
			displayButton.setText("DISPLAY CATALOG");
			displayButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					cc.getItems();
					cc.employeeDisplay();
					setContentPane(cc);
				}
			});
		}
		return displayButton;
	}
	/**
	 * This method initializes saleButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getSaleButton() {
		if (saleButton == null) {
			saleButton = new JButton();
			saleButton.setBounds(new Rectangle(77, 310, 160, 66));
			saleButton.setText("SALE UPDATE");
			saleButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					setContentPane(usc);
				}
			});
		}
		return saleButton;
	}
	
	
	
	
	
}
